package com.log4jviewer;

import java.util.HashSet;
import java.util.Set;

import com.log4jviewer.domain.LogEvent;

public class LogEventContainer {

    private Set<LogEventListener> listeners;

    public LogEventContainer() {
        listeners = new HashSet<LogEventListener>();
    }

    public void notifyListeners(final LogEvent logEvent) {
        for (LogEventListener listener : listeners) {
            listener.addLog(logEvent);
        }
    }

    public void addListener(final LogEventListener listener) {
        if (listener != null) {
            listeners.add(listener);
        }
    }

    public void removeListener(final LogEventListener listener) {
        listeners.remove(listener);
    }
}
